#delimit;
set logtype text;
log using anes2008.out, replace; 
set more off;
/* Original command to extract data from the full 2008 ANES file 

use V083097 V083098a V083098b V083101d V083101f V083102d V083102f
V083103 V083178d V083178f V083179d V083179f  
using anes_timeseries_2008.dta;
*/

/* read subset of ANES 2008 Data */

insheet using anes2008.csv, comma names case; 

/* create party id variable */
gen partyid7=0 if V083097==1 & V083098a==1;
replace partyid7=1  if V083097==1 & V083098a==5;
replace partyid7=2  if V083097==3 & V083098b==5;
replace partyid7=3  if V083097==3 & V083098b==3;
replace partyid7=4  if V083097==3 & V083098b==1;
replace partyid7=5  if V083097==2 & V083098a==5;
replace partyid7=6  if V083097==2 & V083098a==1;

/* create 3-point party ID scale */

gen partyid3=0 if V083097==1;
replace partyid3=2 if V083097==2;
replace partyid3=1 if V083097>=3;

gen dem=(partyid3==0);
gen rep=(partyid3==2);
gen ind=0 if dem==1 & rep==1;
replace ind=1 if V083097>=3 & V083097<=5;

/* create bush knowledgeable variable */
gen bushkno=6-V083179d if V083179d>0 & V083179d<7;
replace bushkno=5 if V083178d==1;
replace bushkno=4 if V083178d==2;
replace bushkno=2 if V083178d==3;
replace bushkno=1 if V083178d==4;

/* create bush honesty variable */
gen bushhon=6-V083179f if V083179f>0 & V083179f<7;
replace bushhon=5 if V083178f==1;
replace bushhon=4 if V083178f==2;
replace bushhon=2 if V083178f==3;
replace bushhon=1 if V083178f==4;

tab bushhon if partyid7>=4 & partyid7<=6;

/* create mccain knowledgeable variable */
gen mccainkno=6-V083102d if V083102d>0 & V083102d<7;
replace mccainkno=5 if V083101d==1;
replace mccainkno=4 if V083101d==2;
replace mccainkno=2 if V083101d==3;
replace mccainkno=1 if V083101d==4;

/* create mccain honesty variable */
gen mccainhon=6-V083102f if V083102f>0 & V083102f<7;
replace mccainhon=5 if V083101f==1;
replace mccainhon=4 if V083101f==2;
replace mccainhon=2 if V083101f==3;
replace mccainhon=1 if V083101f==4;

/* do trait cross-tabs for Bush and McCain */

tab bushhon mccainhon if partyid7>=4 & partyid7<=6, cell;
tab bushkno mccainkno if partyid7>=4 & partyid7<=6, cell;

/* create variable for Iraq attitudes */

gen iraqworth=(V083103==1) if V083103==1 | V083103==5;

tab bushhon iraqworth if partyid7>=4 & partyid7<=6, col;

/* outsheet V083097 V083098a V083098b V083101d V083101f V083102d V083102f
V083103 V083178d V083178f V083179d V083179f using anes2008.csv, comma
nolabel replace; */

log close;
